package org.example.controller;


import org.example.commonapi.domain.R;
import org.example.service.RankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 排行榜
 */
@RestController
@RequestMapping("/oj/rank")
public class RankController {

    @Autowired
    private RankService rankService;

    /**
     * oj时间排行榜
     *
     * @param page 页数
     * @param size 每页大小
     * @return
     */
    @GetMapping("/oj/time")
    public R<Object> getOjRankTime(@RequestParam("page") Integer page, @RequestParam("size") Integer size) {
        return rankService.getOjRankTime(page, size);
    }

    /**
     * oj内存排行榜
     *
     * @param page 页数
     * @param size 每页大小
     * @return
     */
    @GetMapping("/oj/memory")
    public R<Object> getOjRankMemory(@RequestParam("page") Integer page, @RequestParam("size") Integer size) {
        return rankService.getOjRankMemory(page, size);
    }

    /**
     * OJ单独题目的提交记录
     *
     * @param problemId 题目ID
     * @return
     */
    @GetMapping("/oj/echarts")
    public R<Object> getOjRankEchartsTime(@RequestParam String problemId) {
        return rankService.echarts(problemId);
    }

    /**
     * OJ单独题目提交记录前20
     *
     * @param problemId 题目ID
     * @return
     */
    @GetMapping("/oj/echarts/20")
    public R<Object> getOjRankEchartsTimeTop20(@RequestParam String problemId) {
        return rankService.echarts20(problemId);
    }
    /**
     * OJ单独题目提交统计
     *
     * @param problemId 题目ID
     * @return
     */
    @GetMapping("/oj/statistics")
    public R<Object> getOjRankStatistics(@RequestParam String problemId) {
        return rankService.statistics(problemId);
    }


}
